package org.jeecg.modules.online.config.service.p023a;

import org.apache.commons.lang.StringUtils;
import org.jeecg.modules.online.cgform.consts.ExtendJsonKey;
import org.jeecg.modules.online.cgform.utils.CgformUtil;
import org.jeecg.modules.online.config.p022d.ColumnMeta;
import org.jeecg.modules.online.config.p022d.DataBaseConst;
import org.jeecg.modules.online.config.service.DbTableHandleI;

/* renamed from: org.jeecg.modules.online.config.service.a.d */
/* loaded from: hibernate-re-3.7.1-RC.jar:org/jeecg/modules/online/config/service/a/d.class */
public class DbTableMysqlHandleImpl implements DbTableHandleI {
    @Override // org.jeecg.modules.online.config.service.DbTableHandleI
    public String getAddColumnSql(ColumnMeta columnMeta) {
        return " ADD COLUMN " + m15a(columnMeta) + ";";
    }

    @Override // org.jeecg.modules.online.config.service.DbTableHandleI
    public String getReNameFieldName(ColumnMeta columnMeta) {
        return "CHANGE COLUMN " + columnMeta.getOldColumnName() + " " + m13b(columnMeta) + " ;";
    }

    @Override // org.jeecg.modules.online.config.service.DbTableHandleI
    public String getUpdateColumnSql(ColumnMeta cgformcolumnMeta, ColumnMeta datacolumnMeta) {
        return " MODIFY COLUMN " + m12b(cgformcolumnMeta, datacolumnMeta) + ";";
    }

    @Override // org.jeecg.modules.online.config.service.DbTableHandleI
    public String getMatchClassTypeByDataType(String dataType, int digits) {
        String str = "";
        if (DataBaseConst.f581l.equalsIgnoreCase(dataType)) {
            str = "string";
        } else if ("double".equalsIgnoreCase(dataType)) {
            str = "double";
        } else if ("int".equalsIgnoreCase(dataType)) {
            str = "int";
        } else if ("Date".equalsIgnoreCase(dataType)) {
            str = "date";
        } else if ("Datetime".equalsIgnoreCase(dataType)) {
            str = "datetime";
        } else if (DataBaseConst.f574e.equalsIgnoreCase(dataType)) {
            str = "bigdecimal";
        } else if (ExtendJsonKey.f133f.equalsIgnoreCase(dataType)) {
            str = ExtendJsonKey.f133f;
        } else if ("blob".equalsIgnoreCase(dataType)) {
            str = "blob";
        }
        return str;
    }

    @Override // org.jeecg.modules.online.config.service.DbTableHandleI
    public String dropTableSQL(String tableName) {
        return " DROP TABLE IF EXISTS " + tableName + " ;";
    }

    @Override // org.jeecg.modules.online.config.service.DbTableHandleI
    public String getDropColumnSql(String fieldName) {
        return " DROP COLUMN " + fieldName + ";";
    }

    /* renamed from: a */
    private String m14a(ColumnMeta columnMeta, ColumnMeta columnMeta2) {
        String str = "";
        if ("string".equalsIgnoreCase(columnMeta.getColunmType())) {
            str = columnMeta.getColumnName() + " varchar(" + columnMeta.getColumnSize() + ") " + ("Y".equals(columnMeta.getIsNullable()) ? "NULL" : "NOT NULL");
        } else if ("date".equalsIgnoreCase(columnMeta.getColunmType())) {
            str = columnMeta.getColumnName() + " date " + ("Y".equals(columnMeta.getIsNullable()) ? "NULL" : "NOT NULL");
        } else if ("datetime".equalsIgnoreCase(columnMeta.getColunmType())) {
            str = columnMeta.getColumnName() + " datetime " + ("Y".equals(columnMeta.getIsNullable()) ? "NULL" : "NOT NULL");
        } else if ("int".equalsIgnoreCase(columnMeta.getColunmType())) {
            str = columnMeta.getColumnName() + " int(" + columnMeta.getColumnSize() + ") " + ("Y".equals(columnMeta.getIsNullable()) ? "NULL" : "NOT NULL");
        } else if ("double".equalsIgnoreCase(columnMeta.getColunmType())) {
            str = columnMeta.getColumnName() + " double(" + columnMeta.getColumnSize() + CgformUtil.f233E + columnMeta.getDecimalDigits() + ") " + ("Y".equals(columnMeta.getIsNullable()) ? "NULL" : "NOT NULL");
        } else if ("bigdecimal".equalsIgnoreCase(columnMeta.getColunmType())) {
            str = columnMeta.getColumnName() + " decimal(" + columnMeta.getColumnSize() + CgformUtil.f233E + columnMeta.getDecimalDigits() + ") " + ("Y".equals(columnMeta.getIsNullable()) ? "NULL" : "NOT NULL");
        } else if (ExtendJsonKey.f133f.equalsIgnoreCase(columnMeta.getColunmType())) {
            str = columnMeta.getColumnName() + " text " + ("Y".equals(columnMeta.getIsNullable()) ? "NULL" : "NOT NULL");
        } else if ("blob".equalsIgnoreCase(columnMeta.getColunmType())) {
            str = columnMeta.getColumnName() + " blob " + ("Y".equals(columnMeta.getIsNullable()) ? "NULL" : "NOT NULL");
        }
        String str2 = (str + (StringUtils.isNotEmpty(columnMeta.getComment()) ? " COMMENT '" + columnMeta.getComment() + CgformUtil.f231C : " ")) + (StringUtils.isNotEmpty(columnMeta.getFieldDefault()) ? " DEFAULT " + columnMeta.getFieldDefault() : " ");
        String pkType = columnMeta.getPkType();
        if ("id".equalsIgnoreCase(columnMeta.getColumnName()) && pkType != null && ("SEQUENCE".equalsIgnoreCase(pkType) || "NATIVE".equalsIgnoreCase(pkType))) {
            str2 = str2 + " AUTO_INCREMENT ";
        }
        return str2;
    }

    /* renamed from: b */
    private String m12b(ColumnMeta columnMeta, ColumnMeta columnMeta2) {
        return m14a(columnMeta, columnMeta2);
    }

    /* renamed from: a */
    private String m15a(ColumnMeta columnMeta) {
        return m14a(columnMeta, null);
    }

    /* renamed from: b */
    private String m13b(ColumnMeta columnMeta) {
        return m14a(columnMeta, null);
    }

    @Override // org.jeecg.modules.online.config.service.DbTableHandleI
    public String getCommentSql(ColumnMeta columnMeta) {
        return "";
    }

    @Override // org.jeecg.modules.online.config.service.DbTableHandleI
    public String getSpecialHandle(ColumnMeta cgformcolumnMeta, ColumnMeta datacolumnMeta) {
        return null;
    }

    @Override // org.jeecg.modules.online.config.service.DbTableHandleI
    public String dropIndexs(String indexName, String tableName) {
        return "DROP INDEX " + indexName + CgformUtil.f206d + tableName;
    }

    @Override // org.jeecg.modules.online.config.service.DbTableHandleI
    public String countIndex(String indexName, String tableName) {
        return "select COUNT(*) from information_schema.statistics where table_name = '" + tableName + "'  AND index_name = '" + indexName + CgformUtil.f231C;
    }
}
